'use-strict';
/**
 * 自己实现instanceof
 * 实现原理为利用原型链
 * typeof只能判断原始类型（除了null会输出object）,引用类型都会输出object
 * instanceof 只能判断对象
 * 还有一种判断方法，Object.toString.call();会输出"[object 类型值]"
 */
function myInstanceof(left,right){
    let rightProto = right.prototype;
    let leftValue = left.__proto__;
    while(true){
        if(leftValue === null){
            return false;
        }
        if(leftValue === rightProto){
            return true;
        }
        leftValue = leftValue.__proto__;
    }
}
//test
function Person(value){
    this.name = value;
}
Person.prototype.getName = function(){
    console.log(this.name);
    return this.name;
}
const suyechun = new Person('syc');
console.log(myInstanceof(suyechun,Person));